import os

class XplanetI:
	def execute(self,f, resolution, longitude,latitude, projection, params):
		self.file=f
		self.resolution=resolution
		self.longitude=longitude
		self.latitude=latitude
		self.projection=projection
		self.params=params
		if projection == "No Projection":
			os.system('xplanet -utclabel -num_times 1 -output '+self.file+' -geometry '+resolution+' -longitude '+longitude+' -latitude '+latitude)
		else:
			if projection != "Bonne" or projection != "Gnomonic" or projection != "Mercator":
				os.system('xplanet -num_times 1 -output '+self.file+' -geometry '+resolution+' -longitude '+longitude+' -latitude '+latitude+' -projection '+projection)
			else:
				os.system('xplanet -num_times 1 -output '+self.file+' -geometry '+resolution+' -longitude '+longitude+' -latitude '+latitude+' -projection '+projection+' -proj_param '+params)

	def refreshbackground(self):
		os.system('gconftool -t str -s /desktop/gnome/background/picture_filename '+self.file)

	def update(self):
		self.execute(self.file,self.resolution,self.longitude,self.latitude,self.projection,self.params)
		self.refreshbackground()
		return True
